package com.zsc.wxm.ysh.anjo.house.controller;

import com.zsc.wxm.ysh.anjo.house.service.RentHouseService;
import com.zsc.wxm.ysh.anjo.result.PageResult;
import com.zsc.wxm.ysh.anjo.result.Result;
import com.zsc.wxm.ysh.anjo.service.base.model.resources.dto.RentHouseDTO;
import com.zsc.wxm.ysh.anjo.service.base.model.resources.qo.RentHouseQuery;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 描述：租房管理
 *
 * @author playmaker
 * @since 2021/2/24 23:09
 */
@RestController
@RequestMapping("/house/rent-house")
public class RentHouseController {

    @Resource
    private RentHouseService service;

    @PostMapping("/add")
    @ApiOperation("新增租房记录")
    public Result add(@RequestBody @Validated RentHouseDTO params) {
        service.add(params);
        return Result.ok("添加成功");
    }

    @PostMapping("/list-page")
    @ApiOperation("分页查询")
    public PageResult listPage(@RequestBody RentHouseQuery query) {
        return service.listByPage(query);
    }

    @PutMapping("/update-status/{id}/{status}")
    @ApiOperation("更新状态")
    public Result updateStatus(@PathVariable("id") Long id, @PathVariable("status") Integer status) {
        service.updateStatus(id, status);
        return Result.ok("更改状态成功");
    }


}
